package com.gxa.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gxa.domain.entity.PromotionProduct;
import com.gxa.domain.vo.PromotionProductVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;

@Mapper
public interface PromotionProductMapper extends BaseMapper<PromotionProduct> {
    
    @Select("SELECT pp.detail_id, pp.product_serial_no, " +
            "COALESCE(pi.product_name, '未知商品') as product_name, " +
            "pp.promotion_type_id, " +
            "COALESCE(pt.name, '未知类型') as promotion_type_name, " +
            "pp.discount,pp.promotion_price as promotionPrice, pp.start_time, pp.end_time, pp.status, pp.remark, pp.barcode " +
            "FROM promotion_product pp " +
            "LEFT JOIN product_info pi ON pp.product_serial_no = pi.serial_no " +
            "LEFT JOIN promotion_type pt ON pp.promotion_type_id = pt.id")
    List<PromotionProductVO> selectPromotionProduct();
} 